from selenium.webdriver.common.by import By
from base.base_action import BaseAction


# 培训管理->学习地图页面
class PostLearningPage(BaseAction):

    # 学习地按钮
    post_learning_btn = By.XPATH, "//span[text()='学习地图']"

    # 地图名称搜索框
    map_name_search = By.XPATH, "//input[@placeholder='搜索地图']"

    # 地图类型筛选框
    map_type_filter = By.XPATH, "//input[@placeholder='地图类型']"

    # 选择岗位学习
    select_post_learn = By.XPATH, "/html/body/div[2]/div[1]/div[1]/ul/li[1]/span"

    # 时间筛选框
    time_filter = By.XPATH, "//input[@placeholder='开始日期']"

    # 选择时间
    select_time = By.XPATH, "/html/body/div[3]/div[1]/div[1]/button[2]"
    select_time1 = By.XPATH, "/html/body/div[3]/div[1]/div[1]/button[4]"

    # 状态筛选框
    status_filter = By.XPATH, "//input[@placeholder='状态']"

    # 选择发布状态
    un_publish_status = By.XPATH, "/html/body/div[4]/div[1]/div[1]/ul/li[1]/span"
    publish_status = By.XPATH, "/html/body/div[4]/div[1]/div[1]/ul/li[2]/span"

    # 新增地图按钮
    add_map_btn = By.XPATH, "//span[text()='新增普通地图']"

    # 地图名称输入框
    map_name_input = By.XPATH, "//input[@placeholder='请输入名称']"

    # 下一步按钮
    next_step = By.XPATH, "//span[text()='下一步']"

    # 添加关卡按钮
    add_checkpoint_btn = By.XPATH, "//span[text()='添加关卡']"

    # 关卡名称输入框
    checkpoint_name_input = By.XPATH, "//label[text()='关卡名称']/following-sibling::div//input"

    # 确定按钮
    determine_btn = By.XPATH, "//div/div/div[3]/div/div[3]/div/button[1]/span"

    # 视频课程按钮
    video_courses_btn = By.XPATH, "//span[contains(text(), '视频课程')]"

    # 选择视频
    select_video = "document.getElementsByClassName('el-radio__inner')[19].click();"

    # 确定按钮
    determine_btn1 = "document.getElementsByClassName('el-button el-button--primary')[10].click();"

    # 通关条件输入框
    customs_clearance_condition = By.XPATH, "//span[contains(text(),'条件')]/following::form//input"

    # 下一步按钮
    next_step_btn = "document.getElementsByClassName('el-button el-button--primary')[8].click();"

    # 添加用户按钮
    add_user_btn = By.XPATH, "//span[text()='添加用户']"

    # 全选框
    select_all = "document.getElementsByClassName('el-checkbox__inner')[3].click();"

    # 确定按钮
    determine_btn2 = By.XPATH, "/html/body/div[2]/div/div[3]/div/button[1]/span"

    # 发布按钮
    publish_btn = By.XPATH, "//span[text()='发布']"

    # 点击学习地图按钮
    def click_post_learning_btn(self):
        return self.click(self.post_learning_btn)

    # 输入地图名称
    def input_map_name(self, content):
        return self.input(self.map_name_search, content)

    # 点击地图类型筛选框
    def click_map_type_filter(self):
        return self.click(self.map_type_filter)

    # 选择岗位学习
    def click_select_post_learn(self):
        return self.click(self.select_post_learn)

    # 点击时间筛选框
    def click_time_filter(self):
        return self.click(self.time_filter)

    # 选择时间
    def click_select_time(self):
        self.click(self.select_time)
        self.click_time_filter()
        return self.click(self.select_time1)

    # 状态筛选框
    def click_status_filter(self):
        return self.click(self.status_filter)

    # 选择发布状态
    def click_select_publish_status(self):
        self.click(self.un_publish_status)
        self.click_status_filter()
        return self.click(self.publish_status)

    # 点击新增地图
    def click_add_map_btn(self):
        return self.click(self.add_map_btn)

    # 输入地图名称
    def input_map_name_input(self, content):
        return self.input(self.map_name_input, content)

    # 点击下一步按钮
    def click_next_step(self):
        return self.click(self.next_step)

    # 点击添加关卡
    def click_add_checkpoint_btn(self):
        return self.click(self.add_checkpoint_btn)

    # 输入关卡名称
    def input_checkpoint_name_input(self, content):
        return self.input(self.checkpoint_name_input, content)

    # 点击确定
    def click_determine_btn(self):
        return self.click(self.determine_btn)

    # 点击添加视频
    def click_video_courses_btn(self):
        return self.click(self.video_courses_btn)

    # 选择视频
    def click_select_video(self):
        return self.execute_js(self.select_video)

    # 点击确定按钮
    def click_determine_btn1(self):
        return self.execute_js(self.determine_btn1)

    # 输入通关条件
    def input_customs_clearance_condition(self, content):
        return self.input(self.customs_clearance_condition, content)

    # 点击下一步按钮
    def click_next_step_btn(self):
        return self.execute_js(self.next_step_btn)

    # 点击添加用户按钮
    def click_add_user_btn(self):
        return self.click(self.add_user_btn)

    # 全选用户
    def click_select_all(self):
        return self.execute_js(self.select_all)

    # 点击确定
    def click_determine_btn2(self):
        return self.click(self.determine_btn2)

    # 点击发布按钮
    def click_publish_btn(self):
        return self.click(self.publish_btn)





